home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
wsc4vb24
/
atok.frm
< prev
next >
Wrap
Text File
|
1999-06-02
|
3KB
|
133 lines
VERSION 5.00
Begin VB.Form ATOK
Caption = "ATOK"
ClientHeight = 2475
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 2475
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton bExit
Caption = "EXIT"
Height = 375
Left = 360
TabIndex = 4
Top = 1920
Width = 615
End
Begin VB.OptionButton oCOM2
Caption = "COM2"
Height = 375
Left = 120
TabIndex = 3
Top = 480
Width = 975
End
Begin VB.OptionButton oCOM1
Caption = "COM1"
Height = 255
Left = 120
TabIndex = 2
Top = 120
Width = 1095
End
Begin VB.TextBox eResult
Height = 1935
Left = 1320
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 1
Top = 120
Width = 3255
End
Begin VB.CommandButton bTest
Caption = "Push to send 'AT'"
Height = 735
Left = 120
TabIndex = 0
Top = 960
Width = 1095
End
End
Attribute VB_Name = "ATOK"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim wsc As New wscClass ' instantiates wsc class
Dim ThePort As Long ' COM port
Dim TestState As Integer
Private Sub Sleep(ByVal MilliSec As Long)
Dim Time As Long
Time = SioTimer() + MilliSec
While SioTimer() < Time
Wend
End Sub
Private Sub bExit_Click()
Dim Code As Long
Code = wsc.fDone(ThePort)
End
End Sub
Private Sub bTest_Click()
Dim Code As Long
Dim S As String
Dim NL As String
NL = Chr$(13) + Chr$(10)
If TestState = 0 Then
' open port
Code = wsc.fReset(ThePort, 128, 128)
If Code < 0 Then
S = GetErrorText(Code)
MsgBox S, , "fReset"
Exit Sub
End If
Code = wsc.fBaud(ThePort, 19200)
' set DTR & RTS when talking to modem
Code = wsc.fDTR(ThePort, Asc("S"))
Code = wsc.fRTS(ThePort, Asc("S"))
' transmit AT command (should delay between each character)
eResult.Text = eResult.Text + "Transmitting " + NL + "AT" + NL
Code = wsc.fPutc(ThePort, Asc("A"))
Call Sleep(20)
Code = wsc.fPutc(ThePort, Asc("T"))
Call Sleep(20)
Code = wsc.fPutc(ThePort, 13)
bTest.Caption = "Push to get Response"
TestState = 1
Else
' get response (expect "OK")
eResult.Text = eResult.Text + "Getting Response " + NL
Code = wsc.fGets(ThePort, 32)
If Code > 0 Then
S = wsc.ResultString
eResult.Text = eResult.Text + Left$(S, Code) + NL
Else
eResult.Text = eResult.Text + "No response!" + NL
End If
TestState = 0
bTest.Caption = "Push to send 'AT'"
Code = wsc.fDone(ThePort)
End If
End Sub
Private Sub Form_Load()
ThePort = COM1
TestState = 0
oCOM1.Value = True
End Sub
Private Sub oCOM1_Click()
ThePort = COM1
End Sub
Private Sub oCOM2_Click()
ThePort = COM2
End Sub